<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="Author" content="FengYu">
    <title>Tz-34期Js</title>
    <style>
        *{margin:0;padding:0;font-family: Microsoft YaHei,serif;}
	    li{list-style: none;}

    </style>
    <script src="https://git.oschina.net/cx-fy/personal/raw/master/conmenu.js"></script>
</head>
<body>
<script>
    var json1 = {
        a : 1,
        b : function () {

        },
        e : {
            one : "1st"
        }
    };
    var json2 = {
        c : 3,
        d : 4
    };


    var json3 = new inherit(json1,json2);

    //json3.b.push(3)
    //json3.b[2].h = "h"
    console.log(json3);
    //console.log(json1)

   

    //一对多继承
    function inherit() {
        for(var i=0;i<arguments.length;i++){
            var obj = arguments[i];
            for (var key in obj){
                if(/object/i.test(typeof obj[key])){
                    if(Array.isArray(obj[key])){
                        this[key] = [];
                        for (var j in obj[key]){
                            this[key][j] = obj[key][j]
                        }
                    }else{
                        this[key]= new inherit(obj[key])
                    }
                }else{
                    this[key] = obj[key]
                }
            }

        }
    }









    /*//一对一继承
    function inherit(obj) {
        var obj1 = Array.isArray(obj)?[]:{};
        for (var key in obj){if(/object/i.test(typeof obj[key])){obj1[key] = inherit(obj[key])}else{obj1[key] = obj[key]}}
        return obj1;
    }*/




</script>
</body>
</html>